package bookez.view.util;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;

public class FacesUtil {

	/**
	 * Enqueue an error message to UIComponent with clientId
	 * @param clientId
	 * @param error
	 */
	public static void addErrorMessage( String clientId, FacesMessage error ) {
		getFacesContext().addMessage( clientId, error );
	}//end method addErrorMessage
	
	public static void addInfoMessage( String clientId, FacesMessage info ) {
		getFacesContext().addMessage( clientId, info );
	}//end method addInfoMessage
	
	public static FacesContext getFacesContext() { 
		return FacesContext.getCurrentInstance(); 
	}//end method getFacesContext
	
	public static ServletContext getServletContext() { 
		return (ServletContext) getFacesContext().getExternalContext().getContext(); 
	}//end method getServletContext
	
}//end class FacesUtil
